<template>
	<view class="withdrawal-view">
		<view class="withdrawal-header">
			<!-- <view class="withdrawal-title">{{name}}</view> -->
			<view class="withdrawal-header-title">
				<text>可提现金额</text>
				<view class="header-eye-view">
					<u-icon v-if="eyeShow" name="eye-off" size="40rpx" style="margin-right: 30rpx;"
					@click="closeEye"></u-icon>
					<u-icon v-else name="eye-fill" size="40rpx" @click="openEye"></u-icon>
				</view>
			</view>
			<view class="withdrawal-header-desc" v-if="eyeShow">
				￥{{amount}}
			</view>
			<view class="withdrawal-header-desc" v-else>
				*****
			</view>
		</view>
		<view class="withdrawal-form">
			<view class="withdrawal-form-view">
				<view style="margin-bottom: 30rpx;margin-left: 20rpx;">提现金额</view>
				<view class="withdrawal-form-item">
					<input class="withdrawal-form-input" v-model="form.amount" type="number"
					placeholder="请输入提现金额" placeholder-style="font-size: 13px;color: #666666;margin-left:20rpx;">
					<text style="font-size: 12px;color: #C52B21;" @click="allAmount">全部提现</text>
				</view>
				<view class="order-pay-view">
					<view class="withdrawal-title-view">提现至</view>
					<view class="order-pay-view1" v-if="form.type=='user_money'">
						<view class="order-pay-imagea">
							<text style="margin-left: 20rpx;font-size: 14px;">银行卡</text>
						</view>
						<radio-group>
							<radio value="code" color="#C52B21" :checked="true" />
						</radio-group>
					</view>
					<view class="order-pay-view1" v-else>
						<view style="display: flex;flex-direction: column;">
							<view class="order-pay-imagea">
								<text style="margin:0 0rpx 10rpx 20rpx;font-size: 14px;">余额</text>
							</view>
							<view style="font-size: 10px; color: #C52B21;margin-left: 20rpx;">
								需先提现到余额
							</view>
						</view>
						<radio-group>
							<radio value="user_money" color="#C52B21" :checked="true" />
						</radio-group>
					</view>
				</view>
				<view class="pay-form-view">
					<view class="pay-form-label">支付密码</view>
					<input class="withdrawal-form-input1" v-model="form.paypass" type="number"
					placeholder="请输入支付密码" placeholder-style="font-size: 13px;background:#f4f4f4;padding:10rpx 20rpx;">
				</view>
			</view>
			<view class="pay-form-view11" v-if="form.type == 'spring'" @click="goToUrl('/pages/mine/mine-list/newYear-red')">
				<u-icon name="arrow-right" size="20"></u-icon>
				<view class="with-bottom-tip1">
					新春红包提现记录
				</view>
			</view>
		</view>
		<view class="with-bottom-view">
			<view class="with-bottom-view1" @click="withdraw">
				确定
			</view>
			<view class="with-bottom-tip" v-if="form.type == 'spring'">每月最多可提现三次</view>
		</view>
	</view>
</template>

<script>
	import LableInput from "@/components/form/labelInput.vue"
	export default {
		components:{
			LableInput
		},
		data(){
			return{
				form:{
					amount:'',
					type:'',
					paypass:''
				},
				amount:0,
				// radioValue:'wechart',
				eyeShow:true,
			}
		},
		onLoad(option) {
			console.log(option)
			this.form.type = option.type
			this.amount = option.amount
		},
		methods:{
			goToUrl(path){
				this.$tools.navigateTo(path)
			},
			allAmount(){
				this.form.amount = this.amount
			},
			// radioChange(e){
			// 	this.radioValue = e.detail.value
			// 	if(this.radioValue == 'wechart'){
			// 		this.form.type = 1
			// 	}else if(this.radioValue == 'alipay'){
			// 		this.form.type = 2
			// 	}else{
			// 		this.form.type = 3
			// 	}
			// 	console.log(this.form.type)
			// },
			withdraw(){
				if(this.form.amount==0){
					return uni.showToast({
						title:'请填写金额',
						icon:"none"
					})
				}
				// if(!this.form.paypass){
				// 	return uni.showToast({
				// 		title:'请填写支付密码',
				// 		icon:"none"
				// 	})
				// }
				this.$http.post(this.$api.withdrawal,this.form,{token:true}).then(res=>{
					if(res.code==1){
						uni.showToast({
							title:'提现成功',
							icon:"none"
						})
						setTimeout(function(){
							uni.switchTab({
								url:'/pages/index/index'
							})
						},500)
					}else{
						uni.showToast({
							title:res.msg,
							icon:"none"
						})
					}
				})
			},
			closeEye(){
				this.eyeShow = false
			},
			openEye(){
				this.eyeShow = true
			}
		}
	}
</script>

<style lang="scss">
	.pay-form-view11{
		display: flex;
		align-items: center;
		flex-direction: row-reverse;
		margin-top: 40rpx;
		.with-bottom-tip1{
			font-size: 14px;
			color: #666666;
		}
	}
	.pay-form-view{
		display: flex;
		align-items: center;
		padding-left: 40rpx;
		.pay-form-label{
			margin-right: 30rpx;
			flex-shrink: 0;
		}
		.withdrawal-form-input1{
			padding: 10rpx 20rpx;
			width: 100%;
		}
	}
	.with-bottom-tip{
		font-size: 14px;
		margin-top: 40rpx;
		color: #E83434;
	}
	.withdrawal-title{
		font-size: 18px;
		text-align: center;
		color: #ffffff;
		
	}
	.with-bottom-view{
		display: flex;
		align-items: center;
		justify-content: center;
		margin-top: 100rpx;
		flex-direction: column;
		.with-bottom-view1{
			display: flex;
			align-items: center;
			justify-content: center;
			letter-spacing: 2rpx;
			width: 80%;
			padding: 20rpx 0;
			background: #C52B21;
			border-radius: 20rpx;
			font-size: 15px;
			color: #ffffff;
		}
	}
	.withdrawal-title-view{
		margin-bottom: 30rpx;
		font-size: 13px; 
		color: #333333;
	}
	.order-pay-view{
		background-color: #FFF6DE;
		border-radius: 20rpx;
		margin-top: 30rpx;
		padding-left: 20rpx;
	}
	.order-pay-view1{
		display: flex;
		// align-items: center;
		justify-content: space-between;
		margin-bottom: 30rpx;
	}
	.order-pay-image{
		width: 40rpx;
		height: 40rpx;
	}
	.order-pay-imagea{
		display: flex;
		align-items: center;
	}
	.price-btn{
		position: fixed;
		bottom: 0;
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		background-color: #ffffff;
		border-top-left-radius: 30rpx;
		border-top-right-radius: 30rpx;
		padding: 20rpx 30rpx;
	}
	.withdrawal-form{
		padding: 0 30rpx 30rpx 30rpx;
		.withdrawal-form-view{
			background-color: #FFF6DE;
			border-radius: 30rpx;
			padding: 30rpx;
			margin-top: -120rpx;
			.withdrawal-form-item{
				display: flex;
				align-items: center;
				justify-content: space-between;
				border-bottom: 1px solid #e7e7e7;
				padding-bottom: 20rpx;
			}
		}
	}
	.withdrawal-view{
		background-color: #FFF0CA;
		height: 100vh;
		.withdrawal-header{
			background: url("../../../static/index/05.png") no-repeat;
			background-size: 100% 100%;
			color: #ffffff;
			padding: 30rpx 30rpx 130rpx 30rpx;
			.withdrawal-header-title{
				display: flex;
				align-items: center;
				margin-top: 140rpx;
				.header-eye-view{
					display: flex;
					align-items: center;
					margin-left: 100rpx;
				}
			}
			.withdrawal-header-desc{
				font-size: 20px;
				color: #ffffff;
				padding: 30rpx 0;
			}
		}
	}
</style>